var nowPage = 0;
var projectNameSearch = {
	getData : function() {
		var name = $("#generalSearchTxt").val();
		_projectNameSearchGetData = $("#pageShow").myPagination({
			currPage : 1,
			pageCount : 10,
			pageNumber : 5,
			panel : {
				tipInfo_on : true,
				links : "javascript:void()"
			},
			ajax : {
				onClick : function(page) {
					ZENG.msgbox.show(" 正在加载" + page + "页，请稍后...", 6, 600);
					nowPage = page;
				},
				on : true,
				type : "POST",
				dataType : 'json',
				url : "/app/project!getProjectAdvancedSearch",
				param : {
					"projectName" : name,
				},
				callback : function(data) {
					backUrl.addCookie(data.state);
					if ('success' == data.state) {
						pageCountId = data.pageCount;// 获取总页数
						projectNameSearch.createContent(data.msg);
					} else if (data.state == "error") {
						errorAlert(data.msg);
					}
				}
			}
		});
	},
	createContent : function(data) {
		var dc = $("#dataContent");
		dc.empty();
		var content = "";
		if (data != null && data.length != 0) {
			$("#pageShow").show();
			content = "<tr id='titleTr'><th width='30%' scope='col'>项目名称</th><th width='10%' scope='col'>实施时间</th>"
					+ "<th width='10%' scope='col'>总投资（亿）</th><th width='15%' scope='col'>主管部门</th>"
					+ "<th width='20%' scope='col'>资金来源</th><th width='10%' scope='col'>批示</th>"
					+ "<th width='5%' scope='col'>操作</th></tr>";
			for ( var int = 0; int < data.length; int++) {
				var v = data[int];
				var id = v.id;
				var name = v.name;
				var fund = v.fund;
				var impl = v.impl_time;
				var fundPlan = v.fund_plan;
				var mgrDepart = v.mgr_depart;
				var comment = v.comment;
				var checkout = v.checkout;

				var _name = name;
				if (name.length > 26) {
					name = name.substring(0, 24) + "...";
				}
				var _fundPlan = fundPlan;
				if (fundPlan.length > 17) {
					fundPlan = fundPlan.substring(0, 16) + "...";
				}
				var _mgrDepart = mgrDepart;
				if (mgrDepart.length > 13) {
					mgrDepart = mgrDepart.substring(0, 11) + "...";
				}
				var _comment = "";
				if (Number(comment) == 2) {
					_comment = "<img src='/img/comment.png'>";
				}
				if (Number(checkout) == 1) {
					content += "<tr class='checkout'>";
				} else {
					content += "<tr>";
				}
				content += "<td align='center'><a href='/app/project!getProjectDetailedById?p_id=" + id
						+ "' target='_blank' title='" + _name + "' class='tempClass'>" + name
						+ "</a></td><td align='center'>" + impl + "</td><td align='center'>" + fund
						+ "</td><td align='center' title='" + _mgrDepart + "'>" + mgrDepart
						+ "</td><td align='center' title='" + _fundPlan + "'>" + fundPlan
						+ "</td><td align='center'><font color='red'>" + _comment
						+ "</font></td><td align='center'><a href='javascript:projectNotation.show(" + id
						+ ")'>批示</a></td></tr>";
			}
		} else {
			$("#pageShow").hide();
			content = "<tr id='noData'><td align='center'><h1>暂无数据</h1></td></tr>";
		}
		dc.append(content);
		projectNameSearchPoshytip();
	},
	jumpPage : function() {// 分页跳转
		_projectNameSearchGetData.jumpPage(nowPage);
	}
};
function projectNameSearchPoshytip() {
	$("#dataContent").find("td").poshytip({
		className : 'tip-darkgray',
		showOn : 'hover',
		alignTo : 'target',
		alignX : 'center',
		alignY : "center",
		allowTipHover : true,
		fade : true,
		slide : true
	});
	$(".tempClass").poshytip({
		className : 'tip-darkgray',
		showOn : 'hover',
		alignTo : 'target',
		alignX : 'right',
		alignY : "center",
		offsetX : 10,
		allowTipHover : true,
		fade : true,
		slide : true
	});
};
/**
 * 批示后跳转的方法
 */
function projectNotationJump() {
	projectNameSearch.jumpPage();
}
var onloadProjectNameSearch = {
	onload : function() {
		var name = getUrlParam("projectName");
		name = decodeURI(name);
		if (checkValue(name)) {
			$("#generalSearchTxt").val(name);
		}
		projectNameSearch.getData();
		$("#generalSearchA").click(function() {
			var name = $("#generalSearchTxt").val();
			if (checkSC(name)) {
				errorAlert("项目名称不能包含特殊符号！<br>如<br>英文模式的： ! $ ( ) : ; ? ' \" <br>中英文模式的： / \\ + = @ # & *");
			} else {
				projectNameSearch.getData();
			}
		});
	}
};